<template>
  <el-dropdown trigger="click" @command="changeLanguage">
    <!-- 这里必须加一个div -->
    <div>
      <svg-icon class-name="size-icon" icon-class="language" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="'zh'=== $i18n.locale ">{{ $t('base.langZh') }}</el-dropdown-item>
      <el-dropdown-item command="en" :disabled="'en'=== $i18n.locale ">{{ $t('base.langEn') }}</el-dropdown-item>
      <el-dropdown-item command="tw" :disabled="'tw'=== $i18n.locale ">{{ $t('base.langTw') }}</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import { setStorage } from '@/utils'
export default {
  methods: {
    changeLanguage (lang) {
      setStorage('lang', lang)
      this.$i18n.locale = lang
      this.$message.success('切换多语言成功')
    }
  }
}
</script>
